/**
 * Buffer.h
 *
 *  Created on: 22.03.2010
 *      Author: pascalmuller
 *
 *      Buffer reads fixed amount of char from file.
 *
 *      TODO:
 *      Exception handling.
 *
 */

#ifndef BUFFER_H_
#define BUFFER_H_

#include <stdio.h>

class Buffer {
private:
	FILE* sourcecode;
	int buffer_size;
	char* buffer1;
	char* buffer2;
	//das aktuelle Bufferobjekt
	char* currentBuffer;
	int currentIndex;
	bool isUngetChar;
	void switchBuffer();
	void reloadBuffer();
	void init();


public:
	/**
	 * Opens file "filename" and sets buffersize.
	 */
	Buffer(char* filename);
	char getChar();
	char ungetChar();
	virtual ~Buffer();
};

#endif /* BUFFER_H_ */
